import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace OrderPackageApi {
  /** SPA订单套餐关联信息 */
  export interface OrderPackage {
    id: number; // 主键ID
    orderExtensionId?: number; // 关联spa_order_extension表ID
    packageId?: number; // 关联spa_service_package表ID
    packageName?: string; // 套餐名称
    packagePrice?: number; // 套餐价格
    packageDiscount: number; // 套餐折扣金额
    finalPrice?: number; // 最终价格
    packageStatus: string; // 套餐状态
    packageNotes: string; // 套餐备注
    scope: string; // 权限范围
    scoperef: string; // 权限引用
    orderId?: number; // 订单ID
  }
}

/** 查询SPA订单套餐关联分页 */
export function getOrderPackagePage(params: PageParam) {
  return requestClient.get<PageResult<OrderPackageApi.OrderPackage>>('/spa/order-package/page', { params });
}

/** 查询SPA订单套餐关联详情 */
export function getOrderPackage(id: number) {
  return requestClient.get<OrderPackageApi.OrderPackage>(`/spa/order-package/get?id=${id}`);
}

/** 新增SPA订单套餐关联 */
export function createOrderPackage(data: OrderPackageApi.OrderPackage) {
  return requestClient.post('/spa/order-package/create', data);
}

/** 修改SPA订单套餐关联 */
export function updateOrderPackage(data: OrderPackageApi.OrderPackage) {
  return requestClient.put('/spa/order-package/update', data);
}

/** 删除SPA订单套餐关联 */
export function deleteOrderPackage(id: number) {
  return requestClient.delete(`/spa/order-package/delete?id=${id}`);
}


/** 导出SPA订单套餐关联 */
export function exportOrderPackage(params: any) {
  return requestClient.download('/spa/order-package/export-excel', { params });
}

